import types from './../types/music' ;
export default {
    getMusic:function ({commit} , params) {
        return new Promise((resolve, reject) =>{
            ajax.get({
                url:'/playlist/detail?id=' + params.id,
            }).then((res) => {
                ajax.get({
                    url:'/music/url?id=29246273'//+res.data.playlist.tracks[0].al.id
                }).then((Datas) => {

                    ajax.get({
                        url:'/lyric?id=29246273'//+res.data.playlist.tracks[0].al.id
                    }).then((lyrics) => {
                        let params = {
                            playlist : res.data.playlist.tracks[0],
                            privileges : res.data.privileges ,
                            musicAddress : Datas.data.data[0].url ,
                            lyric : lyrics.data.lrc.lyric
                        }
                        commit(types.GETMUSIC,params)
                        resolve();
                    })
                })
                
            })
            .catch((error) => {
                console.log(error)
            })
                
        })
    },
}